package com.imyours.net.result;

import java.util.ArrayList;
import java.util.List;

/**
 * 执行结果父类
 * 
 * @author SLevenc
 * 
 */
public class ExecuteResult {

	/**
	 * 操作是否成功
	 */
	protected boolean successed = true;
	/**
	 * 结果附加的对象
	 */
	private Object attach = null;

	/**
	 * 错误列表
	 */
	private List<Throwable> exceptions = new ArrayList<Throwable>();

	@Override
	public String toString() {
		StringBuilder sb = new StringBuilder();
		sb.append("successed:").append(this.successed).append("\n");
		sb.append("attach:").append(this.attach).append("\n");
		sb.append("exceptions:").append("\n");
		sb.append("-----------start----------\n");
		for (int i = 0; i < exceptions.size(); i++) {
			sb.append(exceptions.get(i).getMessage()).append("\n");
		}
		sb.append("----------end----------\n");
		return sb.toString();
	}

	/**
	 * 添加到异常列表
	 * 
	 * @param t
	 */
	public void addThrowAble(Throwable t) {
		exceptions.add(t);
	}

	public List<Throwable> getExceptions() {
		return exceptions;
	}

	public void setExceptions(List<Throwable> exceptions) {
		this.exceptions = exceptions;
	}

	public boolean isSuccessed() {
		return successed;
	}

	public void setSuccessed(boolean successed) {
		this.successed = successed;
	}

	public Object getAttach() {
		return attach;
	}

	public void setAttach(Object attach) {
		this.attach = attach;
	}

}
